import 'package:flutter/material.dart';
import 'package:flutter_xyf/model/nav_btn.dart';
import 'package:flutter_xyf/pages/basic_widget/flex_layout/flex_layout.dart';
import 'package:flutter_xyf/pages/basic_widget/layout/layout_size.dart';
import 'package:flutter_xyf/pages/basic_widget/stack_layout.dart';
import 'package:flutter_xyf/pages/component/app_bar/index.dart';
import 'package:flutter_xyf/pages/component/my_btn/index.dart';
import 'package:flutter_xyf/utils/navigator_util.dart';

import 'custom_layout.dart';
import 'sliver_demo/index.dart';

// flutter 布局
class BasicWidget extends StatefulWidget {
  BasicWidget({Key? key}) : super(key: key);

  @override
  _BasicWidgetState createState() => _BasicWidgetState();
}

class _BasicWidgetState extends State<BasicWidget> {
  @override
  void initState() {
    super.initState();
    this.init();
  }

  init() async {}

  @override
  Widget build(BuildContext context) {
    final List<NavBtn> dataList = [
      NavBtn('尺寸约束大小', LayoutSize()),
      NavBtn('flex布局', FlexLayout()),
      NavBtn('stack布局', StackLayout()),
      NavBtn('CustomLayout布局', CustomLayout()),
      NavBtn('Sliver Demo', SliverDemo()),
    ];
    return Scaffold(
        appBar: MyAppBar(
          title: '基础组件和布局',
          isBack: false,
        ),
        body: GridView.builder(
            itemCount: dataList.length,
            gridDelegate:
                SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
            itemBuilder: (_, index) {
              return Padding(
                padding: EdgeInsets.all(10),
                child: MyBtn(
                    text: dataList[index].text,
                    click: () {
                      NavigatorUtil.pushPageByFade(
                          context: context, targetPage: dataList[index].page);
                    }),
              );
            }));
  }
}
